package com.home.common.enums;

/**
 * Description: 文件上传对应文件夹
 * Created by 王大宸 on 2020-10-17 21:26
 * Created with IntelliJ IDEA.
 */
public enum OssFolderEnum {

    FILE_OTHER("0", "other", "其他文件"),
    FILE_AVATAR("1", "avatar", "头像"),
    FILE_DOC("2", "doc", "文档"),
    FILE_MENU("3", "menu", "菜单图标上传"),
    ;

    // 文件山川类型
    private final String type;
    // 上传存放文件夹
    private final String folder;
    // 上传名称
    private final String remarks;

    public String getType() {
        return type;
    }

    public String getFolder() {
        return folder;
    }

    public String getRemarks() {
        return remarks;
    }

    OssFolderEnum(String type, String folder, String remarks) {
        this.type = type;
        this.folder = folder;
        this.remarks = remarks;
    }

    /***
     * 功能说明：根据文件上传的类型,获取对应的文件夹
     *
     * @author 王大宸
     * @date 2020/10/17 21:33
     * @param type 上传文件的类型
     * @return java.lang.String
     */
    public static String getFolderByType(String type) {
        OssFolderEnum[] enums = OssFolderEnum.values();
        for (OssFolderEnum fileFolderEnum : enums) {
            if (fileFolderEnum.getType().equals(type)) {
                return fileFolderEnum.getFolder();
            }
        }
        return FILE_OTHER.getFolder();
    }


}
